package com.enjoyor.soa.traffic.server.efoms.dubbo.manage;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.enjoyor.soa.traffic.core.efoms.domain.CheckDeviceInfo;
import com.enjoyor.soa.traffic.core.efoms.domain.DeviceStatusInfo;
import com.enjoyor.soa.traffic.core.efoms.service.ICheckDeviceInfoService;
import com.enjoyor.soa.traffic.core.efoms.service.IDevStatusInfoService;
import com.enjoyor.soa.traffic.util.helper.ReflectHelper;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import io.swagger.annotations.BasicAuthDefinition;

@Service(timeout = 6000)
public class ManageCheckDeviceInfoService {

	@Autowired
	private ICheckDeviceInfoService checkDeviceInfoService;
	
	@Autowired
	private IDevStatusInfoService devStatusInfoService;
	
	/**
	 * 获取巡检分页信息；
	 * @param DevId：设备编号；
	 * @param devTypeCode：设备类型编号；
	 * @param page：分页信息；
	 * @return resultPojo；
	 */
	public ResultPojo getCheckDeviceInfoPage(String DevId,String devTypeCode,String devName,String ledType,String devStatusCode,String isPingConnect,String checkResultCode,String devAreaCode,String isDelayData,String isHightPackage,String isHightResponse,String isHaveData,String devFactory,String searchFlag,String beginLastPassTime,String endLastPassTime,String isPhotoSuccess,String repStatusCode,String project,String company,String picStatusFlag,Page page){
		return ResultHelper.getResult(this.checkDeviceInfoService.getCheckDeviceInfoPage(DevId,devTypeCode,devName,ledType,devStatusCode,isPingConnect,checkResultCode,devAreaCode,isDelayData,isHightPackage,isHightResponse,isHaveData,devFactory,searchFlag,beginLastPassTime,endLastPassTime,isPhotoSuccess,repStatusCode,project,company,picStatusFlag,page));	
	}
	
	/**
	 * 获取巡检List信息；
	 * @param DevId：设备编号；
	 * @param devTypeCode：设备类型编号；
	 * @return resultPojo；
	 */
	public ResultPojo getCheckDeviceInfoList(String DevId,String devTypeCode,String devName,String ledType,String devStatusCode,String isPingConnect,String checkResultCode,String devAreaCode,String isDelayData,String isHightPackage,String isHightResponse,String isHaveData,String devFactory,String searchFlag){
		List<CheckDeviceInfo> list = this.checkDeviceInfoService.getCheckDeviceInfoList(DevId,devTypeCode,devName,ledType,devStatusCode,isPingConnect,checkResultCode,devAreaCode,isDelayData,isHightPackage,isHightResponse,isHaveData,devFactory,searchFlag);
		return ResultHelper.getResult(ReflectHelper.listToList(list, CheckDeviceInfo.class));
	}
	
	/**
	 * 获取巡检信息对象；
	 * @param DevId
	 * @return resultPojo
	 */
	public ResultPojo getCheckDeviceInfo(String DevId){
		CheckDeviceInfo checkDeviceInfo = this.checkDeviceInfoService.getCheckDeviceInfo(DevId);
		return ResultHelper.getResult(ReflectHelper.beanToBean(checkDeviceInfo, CheckDeviceInfo.class));
	}
	
	/**
	 * 获取巡检数量的查询；
	 * @param beginTime:开始时间；
	 * @param endTime：结束时间；
	 * @return resultPojo
	 */
	public ResultPojo getCheckCount(String beginTime,String endTime,String devTypeCode){
		ResultPojo resultPojo = new ResultPojo();
		resultPojo = this.checkDeviceInfoService.getCheckCount(beginTime, endTime,devTypeCode);
		return resultPojo;
	}
	
	/**
	 * 手动刷新巡检结果；
	 * @param devTypeCode
	 * @return
	 */
	public ResultPojo reFreshCheckResult(String devTypeCode){
		ResultPojo resultPojo = new ResultPojo();
		DeviceStatusInfo deviceStatusInfo = new DeviceStatusInfo();
		deviceStatusInfo.setDevTypeCode(devTypeCode);
		this.devStatusInfoService.refreshCheckResult(deviceStatusInfo);
		return resultPojo;
	}
}
